package com.chaos.eurekaproducer;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.chaos.eurekaproducer.domain.User;
import com.chaos.eurekaproducer.redis.CurrentLimiting;
import com.chaos.eurekaproducer.redis.RedisDelayingQueue;
import com.chaos.eurekaproducer.utils.MyRejectionHandler;
import com.chaos.eurekaproducer.utils.MyThreadPoolUtils;
import org.apache.commons.lang3.StringUtils;
import org.redisson.Redisson;
import org.redisson.api.RKeys;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import redis.clients.jedis.Jedis;

import java.math.BigDecimal;
import java.math.MathContext;
import java.util.*;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author liaopeng
 * @title: mainTest
 * @projectName eureka-producer
 * @description: TODO
 * @date 2021/11/13下午9:01
 */
public class mainTest {
    public static void main(String[] args) {
        longestPalindrome("abaabbba");
    }

    public static String longestPalindrome(String s) {
        if (s == null || s.length() <= 1) {
            return s;
        }
        int start = 0,end = 0;
        for (int i = 0; i < s.length(); i++) {
            int len1 = extends1(i,i,s);
            int len2 = extends1(i,i+1,s);
            int len = Math.max(len1,len2);
            if (len > end - start) {
                start = i - len/2;
                end = i + len/2;
            }
        }




        return s.substring(start,end);
    }

    public static int extends1(int i,int j,String s){
        int len = 0;
        while (i >=0 && j <= s.length() && s.charAt(i) == s.charAt(j)) {
            len = j - i;
            i--;
            j++;
        }
        return len;
    }
}
